// Copyright (c) 2013-2013,  6932401@qq.com
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or 
// without modification, are permitted provided that the 
// following conditions are met.
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above 
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials 
// provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
// CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef __LIGHTUI_H____
#define __LIGHTUI_H____

#include "LightControl.h"

class CLightUI: public CWindowWnd
{
public:
	explicit CLightUI(LPCWSTR lpTitle, LPCWSTR lpWindowClass);
	virtual ~CLightUI(void);
public:
	//	
	//
	void SetTransparent(HDC hMemDc, BOOL bTransparent);
	void SetCorner(const RECT &rc);
protected:
	void Paint(HDC hdc, const Gdiplus::Rect &rcPaint);
	void RemoveControl(CControlUI *pControl, BOOL bDelete);
	
	//event
	LRESULT OnMouseEvent(const POINT &pt, MOUSE_SHIFT_STATE msState);
	LRESULT ControlHandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
	virtual BOOL TerminateUI(BOOL bPostQuit = TRUE);
	//
	virtual void Layout(const RECT &rc); 
	virtual LRESULT OnClick(LPARAM lParam); 
	void InvalidateMem(const RECT &rcPaint);
	virtual void OnBackgroundChanged();
	virtual LPCTSTR GetWindowClassName();
	virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 
    BOOL OnNCHitTest(LPARAM lParam, LRESULT &lRes);
	BOOL OnNCPaint(WPARAM wParam, LPARAM lParam, LRESULT &lRes);
	//Ë¢ÐÂ
	void Invalidate();
	//
	void UpdateWindow();
protected: 
	BLENDFUNCTION m_Blend;
	HINSTANCE m_hInstance;
	TCHAR m_szTitle[MAX_PATH];	
	TCHAR m_szWindowClass[MAX_PATH];
	//
	CImageUI *m_pBKGImage;
	CResButton *m_pClose;
	CResButton *m_pMin;
	CLabelUI *m_pCaption;
	CImageUI *m_pLogo;
	//
	std::vector<CControlUI *> m_ControlList;

	HDC  m_hMemDc;
	HBITMAP m_hMemBitmap; 
	BOOL m_bEraseBkg;
	RECT m_rcCorner; 
};

#endif

